# Contributor: Sergiy Stupar <owner@sestolab.pp.ua>
# Maintainer: Sergiy Stupar <owner@sestolab.pp.ua>
pkgname=json2tsv
pkgver=1.1
pkgrel=0
pkgdesc="JSON to TSV converter"
url="https://codemadness.org/json2tsv.html"
arch="all"
license="ISC"
subpackages="$pkgname-doc $pkgname-jaq::noarch $pkgname-jaq-doc:jaq_doc"
source="https://codemadness.org/releases/json2tsv/json2tsv-$pkgver.tar.gz"
options="!check" # No tests

build() {
	make
}

package() {
	make MANPREFIX=/usr/share/man PREFIX=/usr DESTDIR="$pkgdir" install

	# conflicts with jaq package
	mv "$pkgdir"/usr/bin/jaq "$pkgdir"/usr/bin/json2tsv-jaq
	mv "$pkgdir"/usr/share/man/man1/jaq.1 "$pkgdir"/usr/share/man/man1/json2tsv-jaq.1
	gzip -9n "$pkgdir"/usr/share/man/man1/*.1
}

jaq() {
	pkgdesc="$pkgdesc (shellscript wrapper)"
	depends="$pkgname=$pkgver-r$pkgrel"

	amove usr/bin/json2tsv-jaq
}

doc() {
	pkgdesc="$pkgdesc (documentation)"
	install_if="docs $pkgname-jaq=$pkgver-r$pkgrel"

	amove \
		usr/share/man/man1/json2tsv.1* \
		usr/share/doc
}

jaq_doc() {
	pkgdesc="$pkgdesc (shellscript wrapper documentation)"
	install_if="docs $pkgname-jaq=$pkgver-r$pkgrel"

	amove usr/share/man/man1/json2tsv-jaq.1*
}

sha512sums="
3166a32ad2ba09e1f54915322ccf68324c67486e5374045b2a70784dc4b97d7cc55af2d516cf4d011942fe18337005032cead10ddf8c7942cfb7c1af44294a8c  json2tsv-1.1.tar.gz
"
